<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel common\models\FileSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Files');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="file-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a(Yii::t('app', 'Create File'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?= GridView::widget([
        'tableOptions' => ['class' => 'table table-condensed table-bordered table-striped table-hover'],
        'pager' => [
//            'class'          => GoPager::className(),
            'nextPageLabel'  => Yii::t('app', 'Next Page'),
            'prevPageLabel'  => Yii::t('app', 'Previous Page'),
            'firstPageLabel' => Yii::t('app', 'First Page'),
            'lastPageLabel'  => Yii::t('app', 'Last Page'),
            'options' => [
                'class' => 'pagination pagination-sm m-t-none m-b-none',
            ],
        ],
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            [
                'class' => 'yii\grid\SerialColumn',
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 25px;'],
            ],
//            'file_id',
//            [
//                'attribute' => 'file_name',
//                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
//                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'white-space: normal; width: 100px;'],
//            ],
            [
                'attribute' => 'file_base_name',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'white-space: normal; width: 80px;'],
            ],
            [
                'attribute' => 'file_extension',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 20px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'white-space: normal; width: 20px;'],
            ],
//            [
//                'attribute' => 'file_path',
//                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 200px;'],
//                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'white-space: normal; width: 200px;'],
//            ],
            [
                'attribute' => 'file_fullname',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 200px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'white-space: normal; width: 200px;'],
            ],
//             'file_uid',
            [
                'attribute' => 'file_uid',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 50px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'white-space: normal; width: 50px;'],
            ],
            [
                'attribute' => 'file_status',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 50px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'white-space: normal; width: 50px;'],
            ],
             'file_rows',
             'file_result_code',
             'file_rows_insert',
             'file_rows_update',
             'file_rows_skip',
             'file_rows_error',
            [
                'attribute' => 'file_task_type',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 50px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'white-space: normal; width: 50px;'],
            ],
            // 'file_created_by',
            [
                'attribute' => 'file_created_at',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 50px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'white-space: normal; width: 50px;'],
            ],
            // 'file_updated_by',
            // 'file_updated_at',

            [
                'class'         => 'yii\grid\ActionColumn',
                'template'      => '{generate-task} {view} {update} {delete}',
                'header'        => '操作',
                'headerOptions' => ['class' => 'text-center no-margin'],
                'buttons'       => [
                    'generate-task' => function($url, $model, $key) {
                        $options = [
                            'title' => Yii::t('app', 'Generate Task'),
                            'data-id' => $key,
                        ];
                        return Html::a('<span class="	glyphicon glyphicon-tasks edit-class"></span>', $url, $options);
                    },
                ],
            ],
        ],
    ]); ?>
</div>
